package com.njtoyo.taxi.admin.mapper.master.mapper.data;

import cn.hutool.core.date.DateTime;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njtoyo.taxi.admin.library.Const;
import com.njtoyo.taxi.admin.mapper.master.enums.SimpleCallRideCategory;
import com.njtoyo.taxi.admin.rest.presenter.data.funnel.CancelDataVO;
import com.njtoyo.taxi.admin.rest.wrapper.open.funnel.FunnelRealTimeCallListWrapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Repository
@DS(Const.PRIMARY_DS)
public interface OpenFunnelMapper {
    List<Map<String, Object>> get30DayCalls(@Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> get30DaySimpleCalls(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectRealTimeGroupByHour(@Param("cantonId") Integer cantonId, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd);

    List<Map<String, Object>> selectDrverRealTimeSendAndGrapByDay(@Param("cantonId") Integer cantonId, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd);

    List<Map<String, Object>> selectDrverSimpleSendAndGrapByDay(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectDrverRealTimeSendByHour(@Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectDrverSimpleCallSendByHour(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectDriverRealTimeGrabByHour(@Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectDriverSimpleCallGrabByHour(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> getSimpleCallRideJoinDriver(@Param("callId") String callId);

    List<Map<String, Object>> getRealTimeCancelAnalyse(@Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> getSimpleCallCancelAnalyse(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    Integer getRepeatNum(@Param("callIds") List<Long> callIds);

    Integer getSimpleCallRepeatNum(@Param("callIds") List<Long> callIds);

    List<Map<String, Object>> getRealTimeCancelCall(@Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId, @Param("cancelType") Integer cancelType);

    List<Map<String, Object>> getSimpleCallCancel(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<FunnelRealTimeCallListWrapper> getRidesByCallIds(@Param("callIds") List<Long> callIds);

    IPage<FunnelRealTimeCallListWrapper> getRealTimeCalls(Page<FunnelRealTimeCallListWrapper> page, @Param("cantonId") Integer cantonId, @Param("startDate") DateTime startDate, @Param("endDate") DateTime endDate);

    List<Map<String, Object>> selectRealTimeRepeatCallNum(@Param("cantonId") Integer cantonId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    List<Map<String, Object>> selectSimpleRepeatCallNum(@Param("categorys") List<SimpleCallRideCategory> categorys, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<CancelDataVO> getCancelList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectSendDriverNumByCallIds(@Param("callIds") List<Long> callIds, @Param("category") Integer category);

    List<Map<String, Object>> selectSendDriverByCallIds(@Param("callIds") List<Long> callIds, @Param("category") Integer category);

    int waitOrderDriver(@Param("cantonId") Integer cantonId);

    int operationDriver(@Param("cantonId") Integer cantonId);

    Page<Map<String, Object>> getScanRide(Page page, @Param("startDate") String startDate, @Param("endDate") String endDate);

    void saveActivityReward(@Param("callId") Long callId, @Param("grantedId") Long grantedId, @Param("rewardCategory") Integer rewardCategory,
                            @Param("rewardValue")
                            String rewardValue,
                            @Param("driverRegionId")
                            String driverRegionId,
                            @Param("customerRegionId")
                            String customerRegionId);
}
